package com.chapter11.chap_exercise;

public class TestFrock {
    public static void main(String[] args) {

        //分两次调用getNextNum
        System.out.println(Frock.getNextNum());
        System.out.println(Frock.getNextNum());

        //创建三个Frock对象，并打印三个对象序列号serialNumber，并验证是否按照100递增
        Frock frock = new Frock();
        System.out.println(frock.getSerialNumber());

        Frock frock1 = new Frock();
        System.out.println(frock1.getSerialNumber());

        Frock frock2 = new Frock();
        System.out.println(frock2.getSerialNumber());


    }
}

class Frock{

    public Frock() {
        this.serialNumber = getNextNum();
    }

    //私有固态属性currentNum(int) 100000
    private static int currentNum = 100000;

    public static int getNextNum(){
        currentNum += 100;
        return currentNum;
    }



    private int serialNumber;   //序列号属性

    public int getSerialNumber() {
        return serialNumber;
    }
}




















